{% extends 'admin/base.html' %}

{% block content %}
    <section class="content-header">
        <h1>微电影管理系统</h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 预告管理</a></li>
            <li class="active">
                {% if request.path == url_for('admin.preview_add') %}
                    添加预告
                {% else %}
                    修改预告
                {% endif %}
            </li>
        </ol>
    </section>
    <section class="content" id="showcontent">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            {% if request.path == url_for('admin.preview_add') %}
                                添加预告
                            {% else %}
                                修改预告
                            {% endif %}
                        </h3>
                    </div>
                    <form role="form" method="post" enctype="multipart/form-data">
                        <div class="box-body">
                            {% include 'admin/shared/_alertinfo.html' %}
                            <div class="form-group">
                                <label for="input_title">{{ form.title.label }}</label>
                                {{ form.title }}
                                {% for err in form.title.errors %}
                                    <div class="col-md-12" style="color: red">{{ err }}</div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_logo">{{ form.logo.label }}</label>
                                {{ form.logo }}
                                {% for err in form.logo.errors %}
                                    <div class="col-md-12" style="color: red">{{ err }}</div>
                                {% endfor %}
                                {% if request.path != url_for('admin.preview_add') %}
                                    <img src="{{ url_for('static', filename="media/"+preview.logo) }}" data-src="holder.js/700x320" style="margin-top:5px;" class="img-responsive" alt="">
                                {% endif %}
                            </div>
                        </div>
                        {{ form.csrf_token }}
                        <div class="box-footer">
                            {{ form.submit }}
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

{% block js %}
    <script>
        // 激活菜单栏
        $(document).ready(function () {
            $("#g-4").addClass('active');
            $("#g-4-1").addClass('active');
        })
    </script>
{% endblock %}